'use strict';

const BaseService = require('./base');

class ItemService extends BaseService {
  constructor(ctx) {
    super(ctx, 'Item');
  }
  
  // 重写allList方法，添加分类关联查询
  async allList(where) {
    return this.ctx.model.Item.findAll({
      where,
      order: this.listOrder() || [],
      include: [{
        model: this.ctx.model.ItemCategory,
        as: 'category',
        attributes: ['id', 'category_name']
      }]
    });
  }
}

module.exports = ItemService;
